"""
1）使用列表推导式，快速创建一个元素为：1、2…10的列表
2）使用列表推导式，快速创建一个元素为：2、4、6、8、10…20的列表
   使用range步长，也可以带有if
3）使用列表推导式，快速创建一个元素为：
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]的列表
   使用多个for
4）创建一个字典：字典key是1-5数字，value是这个数字的2次方
5）将两个列表合并为一个字典
   li1= ['name', 'age', 'gender']
li2 = ['Tom', 20, 'man']
6）提取字典中目标数据
   counts = {'MBP': 268, 'HP': 125, 'DELL': 201, 'Lenovo': 199, 'acer': 99}
 需求：提取上述电脑数量大于等于200的字典数据
7）创建一个集合，数据为下方列表的2次方
   li3 = [1, 1, 2]
"""
import value as value

list1 = [i for i in range(1, 11)]
print(list1)
list2 = [i for i in range(2, 21, 2)]
print(list2)
# if
list3 = [i for i in range(2, 21) if i % 2 == 0]
print(list3)
list4 = [(i, j) for i in range(0, 3) for j in range(0, 3)]
print(list4)

dict1 = {key: key ** 2 for key in range(1, 6)}
print(dict1)

li1 = ['name', 'age', 'gender']
li2 = ['Tom', 20, 'man']
tu = {li1[i]: li2[i] for i in range(len(li1))}
print(tu)

counts = {'MBP': 268, 'HP': 125, 'DELL': 201, 'Lenovo': 199, 'acer': 99}
di = {key: value for key, value in counts.items() if value >= 200}
print(di)

li3 = [1, 1, 2]
set1 = {i ** 2 for i in li3}
print(set1)

# 1）过滤出长度大于3的人名
name = ['tom', 'lily', 'jacks', 'Pe', 'Steven']
di1 = {i for i in name if len(i) > 3}
print(di1)

# 2）得到嵌套列表中每个列表的最后一个元素
list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
di2 = [e[-1] for e in list1]
print(di2)

# 3）员工工资>5000的人加200，否则加500
dict1 = {'name':'张三','salary':6000}
dict2 = {'name':'李四','salary':8000}
dict3 = {'name':'王五','salary':4000}
dict4 = {'name':'吴二','salary':3000}
list2 = [dict1,dict2,dict3,dict4]
# di3=[e['salary']+200 if e['salary']>5000 else e['salary']+500 for e in list2]
di5=[(e['name'],e['salary']+200) if e['salary']>5000 else(e['name'],e['salary']+500) for e in list2]
print(di5)

# 4）找到分数60分以下的人姓名
scores = {
      "Rick Sanchez": 70,
      "Morty Smith": 35,
      "Summer Smith": 82,
      "Jerry Smith": 23,
      "Beth Smith": 98
    }
di4=[e for e in scores if scores[e]<60]

print(di4)